//将一文本信息分类存入不同的文件中
//
#include<stdio.h>
#include<string.h>
int main()
{
	FILE *fp=NULL;
	FILE *fp1=NULL;
	FILE *fp2=NULL;
	FILE *fp3=NULL;
	FILE *fp4=NULL;
	FILE *fp5=NULL;
	FILE *fp6=NULL;
	FILE *fp7=NULL;
	FILE *fp8=NULL;
	char buff[255];

//将文本中拆分成各类文本
	fp=fopen("GPS.txt","r");
	fp1=fopen("GNGGA.txt","a+");
	fp2=fopen("GNGSA.txt","a+");
	fp3=fopen("GPGSV.txt","a+");
	fp4=fopen("BDGSV.txt","a+");
	fp5=fopen("GNRMC.txt","a+");
	fp6=fopen("GNVTG.txt","a+");
	fp7=fopen("GNGLL.txt","a+");
	fp8=fopen("GNZDA.txt","a+");

	while(!feof(fp))
	{
		memset(buff,0,255);
		fgets(buff,255,(FILE*)fp);

		if(strstr(buff,"$GNGGA")!=NULL)
			fputs(buff,fp1);
		if(strstr(buff,"$GNGSA")!=NULL)
			fputs(buff,fp2);
		if(strstr(buff,"$GPGSV")!=NULL)
			fputs(buff,fp3);
		if(strstr(buff,"$BDGSV")!=NULL)
			fputs(buff,fp4);
		if(strstr(buff,"$GNRMC")!=NULL)
			fputs(buff,fp5);
		if(strstr(buff,"$GNVTG")!=NULL)
			fputs(buff,fp6);
		if(strstr(buff,"$GNGLL")!=NULL)
			fputs(buff,fp7);
		if(strstr(buff,"$GNZDA")!=NULL)
			fputs(buff,fp8);

	}
	fclose(fp);
	fclose(fp1);
	fclose(fp2);
	fclose(fp3);
	fclose(fp4);
	fclose(fp5);
	fclose(fp6);
	fclose(fp7);
	fclose(fp8);
}
